# this file creates maximum entropy variables for schneider-troeger replication
# ---------------------------------------------------------------
setwd("~/Dropbox/Benton-Jordan-Philips/final-JOP-replication")
library(meboot)
library(readxl)

# grab Schneider-Troeger data:
st.data <- read_excel("data/schneider-troeger/st-data.xlsx")
head(st.data)

set.seed(2093999)

create.bootstraps <- function(y, first.obs, last.obs, n) {
  me.boot.store <- meboot(y[first.obs:last.obs], reps = n)
  the.me.boots <- data.frame(me.boot.store$ensemble)
  names(the.me.boots) <- paste0("meboot_y_", 1:n)
  time <- first.obs:last.obs
  combined.boot <- data.frame(time, y[first.obs:last.obs], the.me.boots)
  combined.boot
}
# note that there's an NA for t=1 so starting at t=2
combined.boots1 <- create.bootstraps(st.data$diff_dji, first.obs = 2, last.obs = 3931, n = 2500) # doing 2500 sims b/c we'll stop once we get 1000 but some might not converge
write.csv(combined.boots1, file = "data/schneider-troeger/schneider-troeger-me.csv")
